<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;
    }

    .add_addres_div {
        padding: 0 0.8rem;
    }

    .add_addres_div .add_addres_item {
        height: 2.2rem;
        line-height: 2.2rem;
        border-bottom: 1px solid #e8e8e8;
        position: relative;
    }

    .add_addres_div .add_addres_item span {
        display: inline-block;
        width: 5rem;
        line-height: 2.2rem;
        height: 2.2rem;
        color: #565656;
        font-size: 0.7rem;
    }

    .add_addres_div .add_addres_item input {
        display: inline-block;
        width: 11rem;
        height: 2.2rem;
        line-height: 2.2rem;
        padding-left: 0.5rem;
        color: #838383;
        font-size: 0.6rem;
    }

    .add_addres_div .add_addres_item img {
        position: absolute;
        width: 0.6rem;
        height: 0.8rem;
        top: 0.7rem;
        right: 0;
    }

    .add_addres_div .morendizhi {
        height: 0.8rem;
        font-size: 0.6rem;
        color: #565656;
        margin-top: 0.8rem;
    }

    .add_addres_div .morendizhi img {
        float: left;
        width: 0.8rem;
        height: 0.8rem;
        margin: 0 0.3rem -0.2rem 0;
    }

    .save_btn {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 2.2rem;
        line-height: 2.2rem;
        text-align: center;
        color: #fff;
        background-color: #EB473E;
        font-size: 0.8rem;
    }
</style>

<body>
    <div  id="app" v-cloak>
        <div class="placeholder_div"></div>
        <div class="add_addres_div">
            <div class="add_addres_item">
                <span class="title">姓名</span>
                <input type="text" placeholder="请输入姓名">
            </div>
            <div class="add_addres_item">
                <span class="title">联系电话</span>
                <input type="text" placeholder="请输入联系电话">
            </div>
            <div class="add_addres_item" onclick="selectCity()">
                <span class="title">所在地区</span>
                <input type="text" readonly placeholder="省，市，区" v-model="ssq_showtext">
                <img src="../image/icon_red_location.png" alt="">
            </div>
            <div class="add_addres_item">
                <span class="title">详细地址</span>
                <input type="text" placeholder="请填写详细地址">
            </div>

            <div class="morendizhi" @click="is_radio = is_radio?false:true">
                <img :src="is_radio ? '../image/icon_radio_checked.png':'../image/icon_radio.png'" alt="">
                设为默认地址
            </div>
        </div>

        <div class="save_btn">立即保存</div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            ssq_showtext: "",
            is_radio: false,
            level1_id: 0, // 省级id
            level2_id: 0, // 市级id
            level3_id: 0, // 区级id
        },
        methods: {

        },

    })


    // 省市选择
    function selectCity() {
        var UIActionSelector = api.require('UIActionSelector');
        UIActionSelector.open({
            datas: 'widget://res/city.json',
            layout: {
                row: 5,
                col: 3,
                height: 30,
                size: 12,
                sizeActive: 14,
                rowSpacing: 5,
                colSpacing: 10,
                maskBg: 'rgba(0,0,0,0.2)',
                bg: '#FFFFFF',
                color: '#9B9B9D',
                colorActive: '#f00',
                colorSelected: '#000'
            },
            animation: true,
            cancel: {
                text: '取消',
                size: 12,
                w: 90,
                h: 35,
                bg: '#fff',
                bgActive: '#ccc',
                color: '#888',
                colorActive: '#fff'
            },
            ok: {
                text: '确定',
                size: 12,
                w: 90,
                h: 35,
                bg: '#fff',
                bgActive: '#ccc',
                color: '#888',
                colorActive: '#fff'
            },
            title: {
                text: '请选择',
                size: 12,
                h: 44,
                bg: '#eee',
                color: '#888'
            },
            fixedOn: api.frameName
        }, function (ret, err) {
            if (ret) {
                //alert(JSON.stringify(ret));
                if (ret.eventType == 'ok') { //代表用户点了确认键
                    app.ssq_showtext = ret.level1 + ' ' + ret.level2 + ' ' + ret.level3
                    app.level1_id = ret.selectedInfo[0].id
                    app.level2_id = ret.selectedInfo[1].id
                    app.level3_id = ret.selectedInfo[2].id
                }

            } else {
                alert("网络不通畅，请稍后再试！");
            }
        });
    }
</script>